package vcp.client.statistics;

import java.io.Serializable;
import java.util.ArrayList;

import javax.swing.JPanel;

import vcp.client.interfaces.IVisitor;

public class ActivityStatistics extends StatisticsAbstract
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4458683479045304323L;

	// ****************************************************************************************************************************
	// Setter-Getter methods
	// ****************************************************************************************************************************
	private final ArrayList <ActivityDataHolder> activityStatistics;

	public ArrayList <ActivityDataHolder> getActivityStatistics ()
	{
		return this.activityStatistics;
	}

	private double deviationCanceled;

	public double getDeviationCanceled ()
	{
		return this.deviationCanceled;
	}

	private int medianCanceled;

	public int getMedianCanceled ()
	{
		return this.medianCanceled;
	}

	private double deviationUsed;

	public double getDeviationUsed ()
	{
		return this.deviationUsed;
	}

	private int medianUsed;

	public int getMedianUsed ()
	{
		return this.medianUsed;
	}

	public ActivityStatistics ()
	{
		this.activityStatistics = new ArrayList <>();
	}

	// ****************************************************************************************************************************
	// Public methods
	// ****************************************************************************************************************************
	/**
	 * fill {@link ActivityDataHolder} with params
	 * 
	 * @param numOfUsed
	 * @param numOfCanceled
	 * @param siteName
	 */
	public void add ( int numOfUsed, int numOfCanceled, String siteName )
	{
		ActivityDataHolder activityDataHolder = new ActivityDataHolder();

		activityDataHolder.setNumOfUsed(numOfUsed);
		activityDataHolder.setNumOfCanceled(numOfCanceled);
		activityDataHolder.setSiteName(siteName);

		this.activityStatistics.add(activityDataHolder);
	}

	/**
	 * fill instance with misc info
	 * 
	 * @param medianUsed
	 * @param deviationUsed
	 * @param medianCanceled
	 * @param deviationCanceled
	 */
	public void addParams ( int medianUsed, double deviationUsed, int medianCanceled, double deviationCanceled )
	{
		this.medianUsed = medianUsed;
		this.deviationUsed = deviationUsed;
		this.medianCanceled = medianCanceled;
		this.deviationCanceled = deviationCanceled;
	}

	/**
	 * 
	 * @return Used Series
	 */
	public String getUsedSeries ()
	{
		return "Used";
	}

	/**
	 * 
	 * @return Canceled Series
	 */
	public String getCanceledSeries ()
	{
		return "Canceled";
	}

	// ****************************************************************************************************************************
	// IVisitable methods
	// ****************************************************************************************************************************
	@Override
	public JPanel acceptVisit ( IVisitor visitor )
	{
		return visitor.visit(this);
	}

	// ****************************************************************************************************************************
	// Public inner classes
	// ****************************************************************************************************************************
	/**
	 * 
	 * @author VCP team
	 *         <p>
	 *         ActivityStatistics's helper class, which holds information per
	 *         site
	 *         </p>
	 */
	public class ActivityDataHolder implements Serializable
	{
		/**
		 * 
		 */
		private static final long serialVersionUID = 3271427170444073997L;

		/** limits initialization **/
		private ActivityDataHolder ()
		{

		}

		private int numOfCanceled;

		public int getNumOfCanceled ()
		{
			return this.numOfCanceled;
		}

		public void setNumOfCanceled ( int numOfCanceled )
		{
			this.numOfCanceled = numOfCanceled;
		}

		private int numOfUsed;

		public int getNumOfUsed ()
		{
			return this.numOfUsed;
		}

		public void setNumOfUsed ( int numOfUsed )
		{
			this.numOfUsed = numOfUsed;
		}

		private String siteName;

		public String getSiteName ()
		{
			return this.siteName;
		}

		public void setSiteName ( String siteName )
		{
			this.siteName = siteName;
		}
	}
}
